//
//  ContactViewController.m
//  bondwatch_purecode
//
//  Created by Jason Yuan on 7/22/15.
//  Copyright (c) 2015 Sumridge. All rights reserved.
//

#import "ContactViewController.h"

#define TITLELABELFONT [UIFont fontWithName:@"Arial-BoldMT" size:12.0];
#define LABELFONT [UIFont fontWithName:@"Arial" size:12.0];

@interface ContactViewController ()
{
    UILabel *sumridgeTitleLabel;
    UILabel *addressLabel;
    UILabel *salesEmailTitleLabel;
    UILabel *salesEmailLabel;
    UILabel *operationsEmailTitleLabel;
    UILabel *operationsEmailLabel;
    UILabel *technologyEmailTitleLabel;
    UILabel *technologyEmailLabel;
    UILabel *careersEmailTitleLabel;
    UILabel *careersEmailLabel;
    
    UILabel *salesPhoneTitleLabel;
    UILabel *salesPhoneLabel;
    UILabel *operationsPhoneTitleLabel;
    UILabel *operationsPhoneLabel;
    UILabel *technologyPhoneTitleLabel;
    UILabel *technologyPhoneLabel;
    UILabel *faxLinePhoneTitleLabel;
    UILabel *faxLinePhoneLabel;
}

@end

@implementation ContactViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"Contact Us";
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIBarButtonItem *settingBarButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"Settings"] style:UIBarButtonItemStylePlain target:self action:@selector(settingBarButtonItemPressed:)];
    settingBarButton.tintColor = SUMRIDGECOLOR;
    self.navigationItem.leftBarButtonItem = settingBarButton;
    
    sumridgeTitleLabel = [[UILabel alloc] init];
    sumridgeTitleLabel.font = TITLELABELFONT;
    sumridgeTitleLabel.text = @"SumRidge Partners";
    [self.view addSubview:sumridgeTitleLabel];
    
    [sumridgeTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(5);
        make.top.equalTo(self.view).offset(70);
    }];
    
    addressLabel = [[UILabel alloc] init];
    addressLabel.font = LABELFONT;
    addressLabel.text = @"111 Town Square Place, Suite 320, Jersey City, NJ 07310";
    [self.view addSubview:addressLabel];
    
    [addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(5);
        make.top.equalTo(sumridgeTitleLabel.mas_bottom).offset(2);
    }];
    
    salesEmailTitleLabel = [[UILabel alloc] init];
    salesEmailTitleLabel.font = TITLELABELFONT;
    salesEmailTitleLabel.text = @"Sales";
    [self.view addSubview:salesEmailTitleLabel];
    
    [salesEmailTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(5);
        make.top.equalTo(addressLabel.mas_bottom).offset(10);
    }];
    
    salesEmailLabel = [[UILabel alloc] init];
    salesEmailLabel.font = LABELFONT;
    salesEmailLabel.textColor = [UIColor blueColor];
    salesEmailLabel.text = @"sales@sumridge.com";
    [self.view addSubview:salesEmailLabel];
    
    [salesEmailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(5);
        make.top.equalTo(salesEmailTitleLabel.mas_bottom).offset(2);
    }];
    
    operationsEmailTitleLabel = [[UILabel alloc] init];
    operationsEmailTitleLabel.font = TITLELABELFONT;
    operationsEmailTitleLabel.text = @"Operations";
    [self.view addSubview:operationsEmailTitleLabel];
    
    [operationsEmailTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(5);
        make.top.equalTo(salesEmailLabel.mas_bottom).offset(10);
    }];
    
    operationsEmailLabel = [[UILabel alloc] init];
    operationsEmailLabel.font = LABELFONT;
    operationsEmailLabel.textColor = [UIColor blueColor];
    operationsEmailLabel.text = @"ops@sumridge.com";
    [self.view addSubview:operationsEmailLabel];
    
    [operationsEmailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(5);
        make.top.equalTo(operationsEmailTitleLabel.mas_bottom).offset(2);
    }];
    
    technologyEmailTitleLabel = [[UILabel alloc] init];
    technologyEmailTitleLabel.font = TITLELABELFONT;
    technologyEmailTitleLabel.text = @"Technology";
    [self.view addSubview:technologyEmailTitleLabel];
    
    [technologyEmailTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(5);
        make.top.equalTo(operationsEmailLabel.mas_bottom).offset(10);
    }];
    
    technologyEmailLabel = [[UILabel alloc] init];
    technologyEmailLabel.font = LABELFONT;
    technologyEmailLabel.textColor = [UIColor blueColor];
    technologyEmailLabel.text = @"technology@sumridge.com";
    [self.view addSubview:technologyEmailLabel];
    
    [technologyEmailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(5);
        make.top.equalTo(technologyEmailTitleLabel.mas_bottom).offset(2);
    }];
    
    careersEmailTitleLabel = [[UILabel alloc] init];
    careersEmailTitleLabel.font = TITLELABELFONT;
    careersEmailTitleLabel.text = @"Careers";
    [self.view addSubview:careersEmailTitleLabel];
    
    [careersEmailTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(5);
        make.top.equalTo(technologyEmailLabel.mas_bottom).offset(10);
    }];
    
    careersEmailLabel = [[UILabel alloc] init];
    careersEmailLabel.font = LABELFONT;
    careersEmailLabel.textColor = [UIColor blueColor];
    careersEmailLabel.text = @"careers@sumridge.com";
    [self.view addSubview:careersEmailLabel];
    
    [careersEmailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(5);
        make.top.equalTo(careersEmailTitleLabel.mas_bottom).offset(2);
    }];
    
    salesPhoneTitleLabel = [[UILabel alloc] init];
    salesPhoneTitleLabel.font = TITLELABELFONT;
    salesPhoneTitleLabel.text = @"Sales & Trading";
    [self.view addSubview:salesPhoneTitleLabel];
    
    [salesPhoneTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(self.view.bounds.size.width/2.0 + 5);
        make.top.equalTo(addressLabel.mas_bottom).offset(10);
    }];
    
    salesPhoneLabel = [[UILabel alloc] init];
    salesPhoneLabel.font = LABELFONT;
    salesPhoneLabel.textColor = [UIColor blueColor];
    salesPhoneLabel.text = @"(201) 898-2525";
    [self.view addSubview:salesPhoneLabel];
    
    [salesPhoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(self.view.bounds.size.width/2.0 + 5);
        make.top.equalTo(salesPhoneTitleLabel.mas_bottom).offset(2);
    }];
    
    operationsPhoneTitleLabel = [[UILabel alloc] init];
    operationsPhoneTitleLabel.font = TITLELABELFONT;
    operationsPhoneTitleLabel.text = @"Operations";
    [self.view addSubview:operationsPhoneTitleLabel];
    
    [operationsPhoneTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(self.view.bounds.size.width/2.0 + 5);
        make.top.equalTo(salesPhoneLabel.mas_bottom).offset(10);
    }];
    
    operationsPhoneLabel = [[UILabel alloc] init];
    operationsPhoneLabel.font = LABELFONT;
    operationsPhoneLabel.textColor = [UIColor blueColor];
    operationsPhoneLabel.text = @"(201) 898-2525";
    [self.view addSubview:operationsPhoneLabel];
    
    [operationsPhoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(self.view.bounds.size.width/2.0 + 5);
        make.top.equalTo(operationsPhoneTitleLabel.mas_bottom).offset(2);
    }];
    
    technologyPhoneTitleLabel = [[UILabel alloc] init];
    technologyPhoneTitleLabel.font = TITLELABELFONT;
    technologyPhoneTitleLabel.text = @"Technology";
    [self.view addSubview:technologyPhoneTitleLabel];
    
    [technologyPhoneTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(self.view.bounds.size.width/2.0 + 5);
        make.top.equalTo(operationsPhoneLabel.mas_bottom).offset(10);
    }];
    
    technologyPhoneLabel = [[UILabel alloc] init];
    technologyPhoneLabel.font = LABELFONT;
    technologyPhoneLabel.textColor = [UIColor blueColor];
    technologyPhoneLabel.text = @"(201) 898-2540";
    [self.view addSubview:technologyPhoneLabel];
    
    [technologyPhoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(self.view.bounds.size.width/2.0 + 5);
        make.top.equalTo(technologyPhoneTitleLabel.mas_bottom).offset(2);
    }];
    
    faxLinePhoneTitleLabel = [[UILabel alloc] init];
    faxLinePhoneTitleLabel.font = TITLELABELFONT;
    faxLinePhoneTitleLabel.text = @"Fax Line";
    [self.view addSubview:faxLinePhoneTitleLabel];
    
    [faxLinePhoneTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(self.view.bounds.size.width/2.0 + 5);
        make.top.equalTo(technologyPhoneLabel.mas_bottom).offset(10);
    }];
    
    faxLinePhoneLabel = [[UILabel alloc] init];
    faxLinePhoneLabel.font = LABELFONT;
    faxLinePhoneLabel.text = @"(201) 898-2526";
    [self.view addSubview:faxLinePhoneLabel];
    
    [faxLinePhoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(self.view.bounds.size.width/2.0 + 5);
        make.top.equalTo(faxLinePhoneTitleLabel.mas_bottom).offset(2);
    }];
   
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapLabel:)];
    salesEmailLabel.tag = 1;
    salesEmailLabel.userInteractionEnabled = YES;
    [salesEmailLabel addGestureRecognizer:tap1];
    
    UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapLabel:)];
    operationsEmailLabel.tag = 2;
    operationsEmailLabel.userInteractionEnabled = YES;
    [operationsEmailLabel addGestureRecognizer:tap2];
    
    UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapLabel:)];
    technologyEmailLabel.tag = 3;
    technologyEmailLabel.userInteractionEnabled = YES;
    [technologyEmailLabel addGestureRecognizer:tap3];
    
    UITapGestureRecognizer *tap4 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapLabel:)];
    careersEmailLabel.tag = 4;
    careersEmailLabel.userInteractionEnabled = YES;
    [careersEmailLabel addGestureRecognizer:tap4];
    
    UITapGestureRecognizer *tap5 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapLabel:)];
    salesPhoneLabel.tag = 5;
    salesPhoneLabel.userInteractionEnabled = YES;
    [salesPhoneLabel addGestureRecognizer:tap5];
    
    UITapGestureRecognizer *tap6 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapLabel:)];
    operationsPhoneLabel.tag = 6;
    operationsPhoneLabel.userInteractionEnabled = YES;
    [operationsPhoneLabel addGestureRecognizer:tap6];
    
    UITapGestureRecognizer *tap7 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapLabel:)];
    technologyPhoneLabel.tag = 7;
    technologyPhoneLabel.userInteractionEnabled = YES;
    [technologyPhoneLabel addGestureRecognizer:tap7];
    
}

- (void)settingBarButtonItemPressed:(id)sender {
    [self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];
}

- (void)tapLabel:(id)sender {
    UIGestureRecognizer *recognizer = sender;
    
    switch (recognizer.view.tag) {
        case 1:
        {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto://%@", salesEmailLabel.text]]];
            break;
        }
        case 2:
        {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto://%@", operationsEmailLabel.text]]];
            break;
        }
        case 3:
        {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto://%@", technologyEmailLabel.text]]];
            break;
        }
        case 4:
        {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto://%@", careersEmailLabel.text]]];
            break;
        }
        case 5:
        {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", @"2018982525"]]];
            break;
        }
        case 6:
        {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", @"2018982525"]]];
            break;
        }
        case 7:
        {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@", @"2018982540"]]];
            break;
        }
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
